package cn.java86.print2;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

/**
 * @author oldliu
 * @since 1.0
 */
//打印机
@Service//@Scope("prototype")
public class Printer {
    @Value("惠普-炫彩9000")
    private String brand;//品牌
    @Value("1599")
    private int price;
    //墨水
    @Autowired//byType
    @Qualifier("black")
    private Ink ink;
    @Autowired
    @Qualifier("b5")
    private TextPaper paper;
    public Printer(){
        System.out.println("打印机对象被创建了");
    }

    public Printer(String brand, int price, Ink ink, TextPaper paper) {
        this.brand = brand;
        this.price = price;
        this.ink = ink;
        this.paper = paper;
    }

    //初始化
    public void init(){
        System.out.println("打印机初始化完成");
    }
    public void xiaohui(){
        System.out.println("打印机被销毁了");
    }
    public void doPrint(String str){
        System.out.println("牌子是"+brand+"价格是"+price+"元的打印机开始工作了");
        System.out.println("使用"+ink.getColor()+"打印");
        paper.print(str);
    }

//    public void setBrand(String brand) {
//        this.brand = brand;
//    }
//
//    public void setPrice(int price) {
//        this.price = price;
//    }
//
//    public void setInk(Ink ink) {
//        this.ink = ink;
//    }
//
  //  public void setPaper(TextPaper paper) {
//        this.paper = paper;
//    }
}
